package com.dxq.test.db;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

/**
 * Author: zsh
 * Date: 2023/11/14
 * Describe: 群表（字段）
 */
@DatabaseTable(tableName = "Group")
public class Group implements Serializable {

    public final static String ID_FIELD_NAME = "group_id";

    // id = true:表明这个字段是这条记录的唯一标志符, generatedId = true:表明自动增加的ID
    //序号
    @DatabaseField(generatedId = true, columnName = ID_FIELD_NAME)
    private int group_id;

    //群名称
    @DatabaseField(columnName = "name")
    private String name;

    //创建时间
    @DatabaseField(columnName = "create_time")
    private String create_time;

    //修改时间
    @DatabaseField(columnName = "update_time")
    private String update_time;

    //所属牧场  牧场--外键
    @DatabaseField(columnName = "pasture_id", foreign = true, foreignAutoRefresh = true, foreignAutoCreate = true)
    private Pasture pasture_id;//序号

    @DatabaseField(persisted = false)//如果设置为false，表示这个字段不会写到数据库中
    private int labelSize;//该族群有多少个牲畜

    public int getGroup_id() {
        return group_id;
    }

    public void setGroup_id(int group_id) {
        this.group_id = group_id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public Pasture getPasture_id() {
        return pasture_id;
    }

    public void setPasture_id(Pasture pasture_id) {
        this.pasture_id = pasture_id;
    }

    public int getLabelSize() {
        return labelSize;
    }

    public void setLabelSize(int labelSize) {
        this.labelSize = labelSize;
    }

    public Group() {
    }

    public Group(String name, String create_time, String update_time, Pasture pasture_id) {
        this.name = name;
        this.create_time = create_time;
        this.update_time = update_time;
        this.pasture_id = pasture_id;
    }

    @Override
    public String toString() {
        return "Group{" +
                "group_id=" + group_id +
                ", name='" + name + '\'' +
                ", create_time='" + create_time + '\'' +
                ", update_time='" + update_time + '\'' +
                ", pasture_id=" + pasture_id +
                '}';
    }
}
